#ifndef __BSP_IST8310_H__
#define __BSP_IST8310_H__

//=====================================================================================================
#include "struct_typedef.h"
#include "bsp_i2c.h"

/*-----------------selections
--------------------------------------------------------
@brief:
*/


/*-----------------settings
--------------------------------------------------------
@brief:
*/
#define RSTN_IST8310_GPIO_Port (GPIO_TypeDef*)GPIOG
#define RSTN_IST8310_Pin       (uint32_t)GPIO_PIN_6        

/*-----------------definitions
--------------------------------------------------------
@brief:
*/
//ist8310 I2C通讯寄存器
#define IST8310_IIC_ADDRESS (0x0E << 1) // IST8310的IIC地址
#define IST8310_IIC_READ_MSB (0x80)     // IST8310的SPI读取发送第一个bit为1

//ist8310内部寄存器
#define MAG_SEN 0.3f // 转换成 uT (灵敏度)

#define IST8310_WHO_AM_I 0x00       // ist8310 who am I 寄存器
#define IST8310_WHO_AM_I_VALUE 0x10 // 设备 ID

#define IST8310_WRITE_REG_NUM 4 // IST8310需要设置的寄存器数目

#define IST8310_DATA_READY_BIT 2

#define IST8310_NO_ERROR 0x00

#define IST8310_NO_SENSOR 0x40
//=====================================================================================================

/*-----------------params
--------------------------------------------------------
@brief:
*/
typedef struct ist8310_real_data
{
    uint8_t status;
    fp32 mag[3];
} ist8310_real_data_t;

/*-----------------functions
--------------------------------------------------------
@brief:
*/
//
uint8_t ist8310_init(void);
//
void ist8310_read_over(uint8_t *status_buf, ist8310_real_data_t *mpu6500_real_data);
//
void ist8310_read_mag(fp32 mag[3]);
//

/*----------------- API_h
--------------------------------------------------------
@brief:
*/
//


/*------------------------end-------------------------*/
#endif